<?php
session_start();
//require_once("../config/include.inc.php");
require_once("../config/include_tokyo.inc.php");
require_once("../class/Common_Function.php");

$emailButton = "Send mail button";
$emailContent = "***邮件内容***";
$commonFunction = new Common_Function();

$current_system = $_SESSION['current_system'];


$id = $_GET["id"];
$sendEmailFlag = $_GET["sendEmailFlag"];

$sql = "select * from orders where id=".$id;
$result = $db->Execute($sql);
$emailButton = "<input type='button' value='邮件' onclick=\"sendEmail('".$result->fields['customer_email']."','".$commonFunction->getEmailSubject($result->fields['order_no'],$result->fields['order_site'],$current_system)."')\">";
$emailButton = $emailButton."&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' value='关闭' onclick='doClose()'>";
$order_site = strtolower($result->fields['order_site']);


if($sendEmailFlag == "paymentEmail"){
	//邮件付款方式,only for Hiteclaser/Lucklaser, 通知客户邮件付款 或 PayPal付款;	
	if($order_site == 'hiteclaser'){
		$emailContent = $commonFunction->getEmail_paymentEmail_H($result);
	}else if($order_site == 'lucklaser.jp'){
		$emailContent = $commonFunction->getEmail_paymentEmail_LJ($result);
	}else if($order_site == 'kr.lucklaser'){
		$emailContent = $commonFunction->getEmail_paymentEmail_LK($result);
	}else if($order_site == 'lucklaser'){
		$emailContent = $commonFunction->getEmail_paymentEmail_L($result);
	}else if($order_site == 'canetalaser'){
		$emailContent = $commonFunction->getEmail_paymentEmail_CA($result);
	}
}else if($sendEmailFlag == "askPaymentEmail"){
	//催付款,only for Hiteclaser;
	$emailContent = $commonFunction->getEmail_askPaymentEmail($result);
}else if($sendEmailFlag == "confirmPaymentEmail"){
	//确认付款,only for Hiteclaser/Lucklaser;
	if($order_site == 'hiteclaser'){
		$emailContent = $commonFunction->getEmail_confirmPaymentEmail_H($result);
	}else if($order_site == 'lucklaser.jp'){
		$emailContent = $commonFunction->getEmail_confirmPaymentEmail_LJ($result);
	}else if($order_site == 'kr.lucklaser'){
		$emailContent = $commonFunction->getEmail_confirmPaymentEmail_LK($result);
	}else if($order_site == 'lucklaser'){
		$emailContent = $commonFunction->getEmail_confirmPaymentEmail_L($result);
	}else if($order_site == 'canetalaser'){
		$emailContent = $commonFunction->getEmail_confirmPaymentEmail_CA($result);
	}	
}else if($sendEmailFlag == "sendTrackingNumber"){
	//发快递单给客户
	if($order_site == 'hiteclaser'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_H($result);
	}else if($order_site == 'lucklaser.jp'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_LJ($result);
	}else if($order_site == 'kr.lucklaser'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_LK($result);
	}else if($order_site == 'lucklaser'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_L($result);	
	}else if($order_site == 'civillaser'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_C($result);
	}else if($order_site == 'jp.civillaser'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_CJ($result);
	}else if($order_site == 'laser-door'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_LD($result);
	}else if($order_site == 'kennbikyou'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_K($result);
	}else if($order_site == 'dmicroscope'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_D($result);
	}else if($order_site == 'spycamhidden'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_S($result);
	}else if($order_site == 'canetalaser'){
		$emailContent = $commonFunction->getEmail_sendTrackingNumber_CA($result);
	}	
}else if($sendEmailFlag == "emptyEmail"){
	//生成空邮件
	if($order_site == 'hiteclaser'){
		$emailContent = $commonFunction->getEmail_emptyEmail_H($result);	
	}else if($order_site == 'lucklaser.jp'){
		$emailContent = $commonFunction->getEmail_emptyEmail_LJ($result);
	}else if($order_site == 'kr.lucklaser'){
		$emailContent = $commonFunction->getEmail_emptyEmail_LK($result);
	}else if($order_site == 'lucklaser'){
		$emailContent = $commonFunction->getEmail_emptyEmail_L($result);	
	}else if($order_site == 'civillaser'){
		$emailContent = $commonFunction->getEmail_emptyEmail_C($result);
	}else if($order_site == 'jp.civillaser'){
		$emailContent = $commonFunction->getEmail_emptyEmail_CJ($result);
	}else if($order_site == 'laser-door'){
		$emailContent = $commonFunction->getEmail_emptyEmail_LD($result);
	}else if($order_site == 'kennbikyou'){
		$emailContent = $commonFunction->getEmail_emptyEmail_K($result);
	}else if($order_site == 'dmicroscope'){
		$emailContent = $commonFunction->getEmail_emptyEmail_D($result);
	}else if($order_site == 'spycamhidden'){
		$emailContent = $commonFunction->getEmail_emptyEmail_S($result);
	}else if($order_site == 'canetalaser'){
		$emailContent = $commonFunction->getEmail_emptyEmail_CA($result);
	}	
}


?>
<html xmlns="http://www.w3.org/1999/xhtml">
<!--Begin:head-->
<? $pageTitle = "邮件内容"; ?>
<?php include("../head.php"); ?>
<!--End:head-->


<body>
<?php 

echo "<center>".$emailButton."</center>"; 
//echo "<br><br>";
//echo "<input type=\"button\" value=\"复制\" onclick=\"setTxt()\">";
echo "<div id=\"emailContent\">".$emailContent."</div>"; 

?>

</body>

</html>

<script>
/************发邮件:mailto**************************/
function sendEmail(customer_email,subject){
	window.location.href="mailto:"+customer_email+"?subject="+subject;
}


/************关闭窗口**************************/
function doClose(){
	window.close();
}




</script>

